﻿using IdGen;

namespace CleanLite.Infrastructure.SnowId
{
    public class SnowflakeId : ISnowflakeId
    {
        private readonly IdGenerator _idGenerator;

        public SnowflakeId(int workerId = 1)
        {
            var epoch = new DateTime(2024, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var structure = new IdStructure(41, 10, 12);
            var options = new IdGeneratorOptions(structure, new DefaultTimeSource(epoch));
            _idGenerator = new IdGenerator(workerId, options);
        }

        public long NextId()
        {
            return _idGenerator.CreateId();
        }
    }
}